
/**
 * 从一个路径获取对象
 * @param path 路径格式：level1.level2.obj
 * @param start 开始目录 默认 game.Workspace
 * @returns 
 */
function getPath(path: string, start: Instance = game.Workspace) {
    let node: Instance | undefined = start;
    let pathFind = "";
    path.split(".").forEach((c, i) => {
        pathFind += ((i === 0 ? "." : "") + c)
        if (node) {
            node = node.FindFirstChild(c)
        }
        if (!node) {
            throw ("can not  find path:" + pathFind)
        }
        // print('node:', c, i, node)

    })
    return node
}
export const resource = {

    getPath
}